<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义规则追番</title>
</head>
<body>
    <span>注意，搜索一次后再次使用需要刷新网页，补充规则请修改代码</span><br/>
    <p>搜索后跳转后，请把url的@keyword删除</p>
    <a href="https://gitee.com/h128/anime-enthusiast-navigation" target="_blank">动漫在线免费看网址导航</a>
    <input type="text" placeholder="请输入番剧名称" id="text">
    <button onclick=search()>搜索</button><br/>
    <script>
        const jsonFiles = [
            "1ANI.json",
            "9ciyuan.json",
            "80tv.json",
            "233dm.json",
            "AGE.json",
            "akiamime.json",
            "AnFuns.json",
            "ant.json",
            "BF.Json",
            "brovod.json",
            "ciyuancheng.json",
            "clicli.json",
            "DM84.json",
            "dms.json",
            "eacg.json",
            "FQDM.json",
            "giriGiriLove.json",
            "HZDM.json",
            "IF.json",
            "index.json",
            "kimani.json",
            "libvio.json",
            "LMM.json",
            "mandao.json",
            "mcy.json",
            "mengfan.json",
            "mitang.json",
            "mitaodm.json",
            "MT.json",
            "mwcy.json",
            "MXdm.json",
            "nekodm.json",
            "NT.json",
            "nyafun.json",
            "omofunz.json",
            "pekolove.json",
            "qifun.json",
            "WEDM.json",
            "xfdm.json",
            "xiaobao.json",
            "xiapidm.json",
            "XY.json",
            "yinghua.json",
            "yishijie.json",
            "ziyedm.json"
        ]
        /*var search_list = []
        const http = new XMLHttpRequest()
        for(var i=0;i<jsonFiles.length;i++)
        {
            http.open("get",jsonFiles[i])
            http.onload = function(e)
            {
                //var json = JSON.parse(e.responseText)
                console.log(e.response)
                //search_list.push(json.searchURL)
            }
            http.send()
        }
        console.log(search_list)*/
        // -----ai-----
        var search_list = [];
        var requestsCompleted = 0;

        function handleRequestCompletion() {
            requestsCompleted++;
            if (requestsCompleted === jsonFiles.length) {
            //    console.log(search_list);
            }
        }

        for (var i = 0; i < jsonFiles.length; i++) {
            const http = new XMLHttpRequest();
            http.open("GET", jsonFiles[i]);
            http.onload = function () {
                if (http.status === 200) {
                    try {
                        const json = JSON.parse(http.responseText);
                        if (json.searchURL) {
                            var newUrl = json.searchURL.replace("@keyword","")
                            search_list.push(newUrl);
                        }
                    } catch (error) {
                        console.error(`Error parsing JSON from ${jsonFiles[i]}:`, error);
                    }
                } else {
                    console.error(`Request for ${jsonFiles[i]} failed with status ${http.status}`);
                }
                handleRequestCompletion();
            };
            http.onerror = function () {
                console.error(`Network error for ${jsonFiles[i]}`);
                handleRequestCompletion();
            };
            http.send();
        }
         // 补充规则
        /*var age = "https://agedm.org/search?query="
        var dm84 = "https://dm84.vip/s----------.html?wd="
        var lmm = "https://lmm52.com/vod/search.html?wd="
        var ant = "https://www.mayiyy.co/vodsearch.html?wd="
        var mcy = "https://www.mcydh.com/vodsearch/-------------.html?wd="
        var dldm = "https://www.dqsj.top/index.php/vod/search.html?wd="
        var omofun = "https://cn.211dm.com/search/-------------.html?wd="
        var dmzz = "http://www.yhdongman.cc/search.php?searchword="
        var fcdm = "https://www.fengchedonman.com/vodsearch/-------------.html?wd="
        var zgacgn = "https://zgacgn.com/search.php?searchword="
        var ggf = "https://www.gugu3.com/index.php/vod/search.html?wd="
        var zfz = "https://www.zhuifanzu1.com/vodsearch/-------------.html?wd="*/

        //search_list.push(age,dm84,lmm,ant,mcy,dldm,omofun,dmzz,fcdm)
        //search_list.push(zgacgn,ggf,zfz)
        //console.log(search_list)
        const input = document.getElementById("text")
      //  var search_url_list = []
        function search()
        {
            for(var idx=0;idx<search_list.length;idx++)
            {
                var search_url = search_list[idx]+=input.value
                var a = document.createElement("a")
                a.href = search_url
                a.innerHTML = search_url
                a.target = "_blank"
                document.body.append(a)
                document.body.append(document.createElement("br"))
              //  search_url_list.push(search_url)
            }
        }
    </script>
</body>
</html>